<!--
 * @Author: your name
 * @Date: 2021-04-19 18:56:07
 * @LastEditTime: 2021-04-19 22:37:48
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \undefinedd:\练习\3D分层图像悬停效果.html
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Night</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body{
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;         
            background-color: rgb(9, 22, 37);
        }
        .container{
            position: relative;
            perspective: 2000px;
        }
        .box{
            position: relative;
            width: 220px;
            height: 360px;
            transition: all 0.5s;
            transform-style: preserve-3d;
        }
        .box:hover{
            transform: rotateX(50deg) rotateZ(-50deg);
        }
        .box img{
            position: absolute;
            width: 100%;
            height: 100%;
            box-shadow: 0 0 3px rgb(61, 138, 226);
            transition: all 1.5s;
            transform:  translateZ(0px);
        }
         .box:hover img:nth-child(2){
            transform: translateX(-10px) translateY(10px) translateZ(-10px);
            opacity: 0.8;
        }
        .box:hover img:nth-child(3){
            transform: translateX(-20px) translateY(20px) translateZ(-20px);
            opacity: 0.6;
        }
        .box:hover img:nth-child(4){
            transform: translateX(-30px) translateY(30px) translateZ(-30px);
            opacity: 0.4;
        }
        .box:hover img:nth-child(5){
            transform: translateX(-40px) translateY(40px) translateZ(-40px);
            opacity: 0.2;      
        }
        .box span{
            position: absolute;
            width: 100%;
            height: 100%;
            transition: all 1.5s;
            opacity: 0.1;
        }
        .box:hover span{
            transform: translateX(-50px) translateY(50px) translateZ(-50px);
            box-shadow: 0 0 40px rgb(41, 151, 253);   
            background-color: rgb(41, 151, 253);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="box">
            <img src="img/photo.jpg" alt="x" >
            <img src="img/photo.jpg" alt="x" >
            <img src="img/photo.jpg" alt="x" >
            <img src="img/photo.jpg" alt="x" >
            <img src="img/photo.jpg" alt="x" >
            <span></span>
        </div>
    </div>
</body>
</html>